package com.smalldoor.thread.demo03;

// join方法 插队类型 要强制执行完成join方法才会执行其他的线程
public class JoinThread implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i <= 500; i++) {
            System.out.println("启动join方法后 --> 线程vip开始执行" + i);
        }
    }

    public static void main(String[] args) {
        JoinThread joinThread = new JoinThread();

        Thread thread = new Thread(joinThread);
        thread.start();

        for (int i = 0; i < 1000; i++) {
            if (i == 200) {
                try {
                    thread.join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("主程序main执行" + i);
        }
    }
}
